<?php

class AdministracionController extends Controller
{

 	public function filters()
    {
        return array(
            'accessControl',
        );
    }
	/**
	* Specifies the access control rules.
	* This method is used by the 'accessControl' filter.
	* @return array access control rules
	*/
	public function accessRules()
	{
		return array(
			array('allow',  // allow all users to perform 'index' and 'view' actions
				'actions'=>array('crearNoticia','index','publiProgramada','publicarDescargas','subirArchivo','Bcat'),
				//'users'=>array('@'),
				'roles'=>array('periodista',)
			),

			array('deny',  // deny all users
				'users'=>array('*'),
			),
		);
	}
	/**
	* Displays a particular model.
	* @param integer $id the ID of the seccion to be buscado
	*/
	public function actionBcat()
	{
		
		$name = "Seleccionar categoría";

		echo CHtml::tag('option',
		                  array('value'=>""),CHtml::encode($name),true);

		if(isset($_POST['Categorias']) and !empty($_POST['Categorias']['id']))
		{

			$listaSubCategorias = array();
			if($catSel=Categorias::model()->findByPk($_POST['Categorias']['id']))
				$listaSubCategorias = CHtml::listData($catSel->subCategorias, 'id', 'nombre');

			
		//$listaCodigos = array('era'=>'asdfasdf','asdfad'=>'asdfasdf');
		    foreach($listaSubCategorias as $value => $name)
		    {
		        echo CHtml::tag('option',
		                   array('value'=>$value),CHtml::encode($name),true);
		    }
		}

	}
	public function actionCrearNoticia()
	{
		$this->render('crearNoticia');
	}

	public function actionIndex()
	{
		$this->render('index');
	}

	public function actionPubliProgramada()
	{
		$this->render('publiProgramada');
	}

	public function actionPublicarDescargas()
	{
		$this->render('publicarDescargas');
	}

	public function actionSubirArchivo()
	{
		$this->render('subirArchivo');
	}

	// Uncomment the following methods and override them if needed
	/*
	public function filters()
	{
		// return the filter configuration for this controller, e.g.:
		return array(
			'inlineFilterName',
			array(
				'class'=>'path.to.FilterClass',
				'propertyName'=>'propertyValue',
			),
		);
	}

	public function actions()
	{
		// return external action classes, e.g.:
		return array(
			'action1'=>'path.to.ActionClass',
			'action2'=>array(
				'class'=>'path.to.AnotherActionClass',
				'propertyName'=>'propertyValue',
			),
		);
	}
	*/
}